@extends('admin.layouts.base')

@section('title','文章管理')

@section('pageHeader','文章管理')

@section('pageDesc','DashBoard')

@section('content')

    <div class="row page-title-row" style="margin:5px;">
        <div class="col-md-12 text-right">
            @if(Gate::forUser(auth('admin')->user())->check('admin.article.create'))
                <a href="/admin/atlc/index" class="btn btn-success btn-md">
                    <i class="fa fa-plus-circle"></i> 发布文章
                </a>
            @endif
        </div>
    </div>
    <div class="row page-title-row" style="margin:5px;">
        <div class="col-md-6">
        </div>
        <div class="col-md-6 text-right">
        </div>
    </div>

    <div class="row">
        <div class="col-xs-12">
            <div class="box">

                @include('admin.partials.errors')
                @include('admin.partials.success')
                <div class="box-body">
                    <table id="tags-table" class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th class="hidden-sm">ID</th>
                            <th class="hidden-sm">作者</th>
                            <th class="hidden-sm">分类名称</th>
                            <th class="hidden-sm">标签</th>
                            <th class="hidden-md">文章标题</th>
                            <th class="hidden-md">浏览数</th>
                            <th class="hidden-md">评论数</th>
                            <th class="hidden-md">发布时间</th>
                            <th data-sortable="false">操作</th>
                        </tr>
                        @if ($article)
                            @foreach($article as $v)
                                <tr>
                                    <td>{{ $v->id }}</td>
                                    <td>{{ $v->author }}</td>
                                    <td>{{ $v->cate_name }}</td>
                                    <td>{{ $v->tag_name }}</td>
                                    <td>{{ $v->title }}</td>
                                    <td>{{ $v->comment_num }}</td>
                                    <td>{{ $v->read_num }}</td>
                                    <td>{{ $v->created_at }}</td>
                                    <td data-sortable="false">
                                        <a style="margin:3px;" href="/admin/article/{{ $v->id }}/edit" class="X-Small btn-xs text-success "><i class="fa fa-edit"></i> 编辑</a>
                                        <a style="margin:3px;" href="#" attr="{{ $v->id }}" class="delBtn X-Small btn-xs text-danger"><i class="fa fa-times-circle"></i> 删除</a>
                                    </td>
                                </tr>
                            @endforeach

                        @endif
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
                <div style="position:relative;left:80%">
                    {{ $article->links() }}
                </div>

            </div>
        </div>
    </div>
    </div>
    </div>
    <div class="modal fade" id="modal-delete" tabIndex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        ×
                    </button>
                    <h4 class="modal-title">提示</h4>
                </div>
                <div class="modal-body">
                    <p class="lead">
                        <i class="fa fa-question-circle fa-lg"></i>
                        确认要删除这个标签吗?
                    </p>
                </div>
                <div class="modal-footer">
                    <form class="deleteForm" method="POST" action="/admin/article">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                        <input type="hidden" name="_method" value="DELETE">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="submit" class="btn btn-danger">
                            <i class="fa fa-times-circle"></i>确认
                        </button>
                    </form>
                </div>

            </div>
            @stop

            @section('js')
                <script>
                    $(function () {
                        $("table").delegate('.delBtn', 'click', function () {
                            var id = $(this).attr('attr');
                            $('.deleteForm').attr('action', '/admin/article/' + id);
                            $("#modal-delete").modal();
                        });

                    });
                </script>
            @stop